package com.burst.reptile.modular.zp.warpper;

import java.util.List;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.burst.reptile.common.utils.DateUtil;
import com.burst.reptile.common.utils.ToolUtil;
import com.burst.reptile.framework.constant.ConstantFactory;
import com.burst.reptile.framework.web.warpper.BaseControllerWrapper;
import com.burst.reptile.modular.zp.entity.ZpHeat;
import com.burst.reptile.modular.zp.entity.ZpResources;

public class ZpHeatWrapper extends BaseControllerWrapper<ZpHeat> {

    public ZpHeatWrapper(Page<ZpHeat> page) {
        super(page);
    }
    
    public ZpHeatWrapper(List<ZpHeat> list) {
        super(list);
    }
    
    @Override
    protected void wrapTheMap(ZpHeat heat) {
    	Long articleId = heat.getArticleId();
    	ZpResources resources = ConstantFactory.me().getResources(articleId);
    	if(ToolUtil.isNotEmpty(resources)) {
    		heat.setTitle(resources.getTitle());
    		heat.setReadSize(resources.getReadSize());
    		heat.setPublishTime(resources.getCreateTime());
    	}
    	heat.setTime(DateUtil.timeToFormat(heat.getPublishTime()));
    }

}
